;(function (YK) {
  //可以在YK上面封装一些方法
  YK.add = YK.add || {}
  
  function del(a,b) {
    return a-b;
  }
  YK.del=del;
  
  YK.add=function (a,b) {
    return a+b;
  }
  
  /**
   * 倒计时 moment 参数格式：xxxx-xx-xx xx:xx
   * @param moment
   * @returns {string}
   */

    YK.time= function time(moment) {
    let nowTime = new Date();
    let newTime = new Date(moment);
    let time = newTime.getTime()-nowTime.getTime();
    let l1 = time % (24*3600*1000); //计算天数后剩余的毫秒数
    let l2 = l1 % (3600*1000); //计算小时数后剩余的毫秒数
    let l3 = l2 % (60*1000); //计算分钟数后剩余的毫秒数
    let day = Math.floor(time/(24*3600*1000)); //计算相差天数
    let h = Math.floor(l1/(3600*1000)); //计算相差小时
    let m = Math.floor(l2/(60*1000));//计算相差分
    let s =Math.floor(l3/1000); //计算秒
    let timeString="";
    if(day>0){
      timeString =  `<span style="color: red">${day}天</span> : <span>${h>9?h:'0'+h}小时</span> : <span>${m>9?m:'0'+m}分</span> : <span>${s>9?s:'0'+s}秒</span>`
    }else if(h>0){
      timeString =  `<span style="background-color: #ccc;">${h>9?h:'0'+h}</span> : <span style="background-color: #ccc;">${m>9?m:'0'+m}</span> : <span style="background-color: #ccc;">${s>9?s:'0'+s}</span>`
    }
    return timeString;
  }
  
})(window.YK=window.YK || {});